<template>
  <view class="demo-container">
    <!-- 基础用法 -->
    <view class="demo-block">
      <view class="demo-block__title">基础用法</view>
      <view class="demo-block__content">
        <fu-scroll-list 
          :list="list1"
          @click="onClick"
        />
      </view>
    </view>
    
    <!-- 自定义宽度 -->
    <view class="demo-block">
      <view class="demo-block__title">自定义宽度</view>
      <view class="demo-block__content">
        <fu-scroll-list 
          :list="list2"
          item-width="300rpx"
        />
      </view>
    </view>
    
    <!-- 激活状态 -->
    <view class="demo-block">
      <view class="demo-block__title">激活状态</view>
      <view class="demo-block__content">
        <fu-scroll-list 
          :list="list3"
          :active-index="activeIndex"
          @click="onActiveClick"
        />
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      list1: [
        {
          title: '标题1',
          desc: '描述文字',
          image: '/static/images/1.jpg'
        },
        {
          title: '标题2',
          desc: '描述文字',
          image: '/static/images/2.jpg'
        },
        {
          title: '标题3',
          desc: '描述文字',
          image: '/static/images/3.jpg'
        }
      ],
      list2: [
        {
          title: '标题1',
          desc: '这是一段很长的描述文字，需要换行显示',
          image: '/static/images/1.jpg'
        },
        {
          title: '标题2',
          desc: '这是一段很长的描述文字，需要换行显示',
          image: '/static/images/2.jpg'
        }
      ],
      list3: [
        { title: '选项1' },
        { title: '选项2' },
        { title: '选项3' },
        { title: '选项4' }
      ],
      activeIndex: 0
    }
  },
  methods: {
    onClick({ item, index }) {
      uni.showToast({
        title: `点击了${item.title}`,
        icon: 'none'
      })
    },
    onActiveClick({ index }) {
      this.activeIndex = index
    }
  }
}
</script>

<style lang="scss" scoped>
.demo-container {
  padding: 20rpx;
}

.demo-block {
  margin-bottom: 30rpx;
  
  &__title {
    margin-bottom: 20rpx;
    font-size: var(--fu-font-size-lg);
    color: var(--fu-text-color);
  }
  
  &__content {
    background-color: #f5f5f5;
    border-radius: var(--fu-radius-base);
    overflow: hidden;
  }
}
</style> 